<template>
	<view>
		<u-navbar title-color="#333" title-bold title-size="36" title="消息" :border-bottom="false"></u-navbar>	
		<view class="kong" v-if="datalist.length==0">
			<view class="text_center">
				暂无消息
			</view>
		</view>
		<view class="maindiv" v-else>
			<view class="me-item flex flex_sb" v-for="(item,index) in datalist" :key="index" @click="todetail(item)">
				<view class="">
					<view class="font_weight font_15_333   flex">
						<view class="hongdian"></view>
						<view class="leftdiv line_1 u-m-l-10">
							{{item.title}}
						</view>
					</view>
					<view class="time font_12_666 u-m-t-20">
						{{item.created_at}}
					</view>
				</view>
				<view class="">
					<u-icon name="arrow-right" color="#999" size="24"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				total:0,
				pageNum:1,
				pageSize:10,
				
				datalist:[],
			}
		},
		onReachBottom() {
			if (this.pageNum * this.pageSize > this.total) {
				// uni.hideNavigationBarLoading();
			} else {
				this.pageNum++;
				this.getList()
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			todetail(e){
				uni.navigateTo({
					url:"/pages/mine/messageDetail?id="+e.id
				})
			},
			getList() {
				this.$api({
					url: '/getNoticeList',
					method: 'get',
					data: {
						token: uni.getStorageSync("token"),
						page:this.pageNum,
						limit:this.pageSize,
						
					},
				}).then(res => {
					if (res.code == 1) {
						this.total=res.data.count
						let data = res.data.list
						if (this.pageNum == 1) {
							this.datalist = data
						} else {
							this.datalist = [...this.datalist, ...data]
						}
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.kong{
		font-weight: 500;
		font-size: 26rpx;
		color: #999999;
		margin-top: 20rpx;
		image{
			margin: 0 auto;
			margin-top: 46rpx;
			width: 320rpx;
			height: 290rpx;
		}
	}
	
	.maindiv{
		padding: 0 32rpx;
		.me-item{
			width: 686rpx;
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin-top: 22rpx;
			padding: 24rpx;
			padding-top: 42rpx;
			
			.leftdiv{
				font-size: 32rpx;
				color: #000000;
				width: 512rpx;
			}
			.hongdian{
				width: 16rpx;
				height: 16rpx;
				background: #FF3B30;
				border-radius: 50%;
			}
		}
	}
</style>
